<!DOCTYPE html>
<html lang="zh-cn">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>修改密码</title>
<!-- Bootstrap -->
<link href="./css/bootstrap.min.css"
	rel="stylesheet">
<link href="./css/profile_style.css" rel="stylesheet">
<link href="./css/response.css" rel="stylesheet">
<link href="./css/bootstrapValidator.css" rel="stylesheet">
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
      <script src="http://cdn.bootcss.com/html5shiv/3.7.2/html5shiv.min.js"></script>
      <script src="http://cdn.bootcss.com/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
<script src="./js/lib/jquery.min.js"></script>
<!-- Include all compiled plugins (below), or include individual files as needed -->
<script src="./js/lib/bootstrap.min.js"></script>
<script src="./js/lib/bootstrapValidator.min.js"></script>
<script src="./js/lib/style.js"></script>
<script type="text/javascript">
$(function (){
	 $('#fm').bootstrapValidator({
       live: 'disabled',
       message: '输入有误',
       feedbackIcons: {
           valid: 'glyphicon glyphicon-ok',
           invalid: 'glyphicon glyphicon-remove',
           validating: 'glyphicon glyphicon-refresh'
       },
       fields: {
           password: {
               validators: {
                   notEmpty: {
                       message: '<span style="font-size:1.2em;">旧密码不能为空！</span>'
                   }
               }
           },
           newPassword : {
        	   validators : {
        		   notEmpty : {
        			   message : '<span style="font-size:1.2em;">新密码不能为空！</span>'
        		   },
        		   stringLength: {
                       min: 6,
                       max: 16,
                       message: '<span style="font-size:1.2em;">新密码在6到16位之间！</span>'
                   },
        		   different : {
        			   field : 'password',
        			   message : '<span style="font-size:1.2em;">新密码不能与旧密码相同！</span>'
        		   }
        	   }
           }, 
           reNewPassword: {
               validators: {
                   notEmpty: {
                       message: '<span style="font-size:1.2em;">确认密码不能为空！</span>'
                   },
                   identical: {
                       field: 'newPassword',
                       message: '<span style="font-size:1.2em;">新密码与确认密码不一致！</span>'
                   }
               }
           }
       }
	 });
});
function updatePassword(){
	$('#fm').bootstrapValidator('validate');
	if ($('#fm').data('bootstrapValidator').isValid()){
		var password = $("#password").val();
		var newPassword = $("#newPassword").val();
		$.ajax({
			url : "http://www.udppvr.cn:80/profile/updatePassword.do",
			data : {
				id : $("#memberId").val(),
				password : password,
				newPassword : newPassword
			},
			success : function (rs){
				if(rs.iserror == true) {
					$("#modelText").text(rs.message);
					$('#myModal').modal();
				}else{
					$("#modelText").text("修改成功，下次使用新密码登录！！");
					$('#myModal').modal();
				}
			},
			dataType : 'json'
		});
	}
}
</script>
</head>
<body>
	<h1 class="logo">修改密码</h1>
	<br />
	<form id="fm" method="post">
		<div class="form-group">
			<input type="hidden" id="memberId" name="tmember.id" value="32892"/>
			<input type="password" class="form-control input-lg" id="password" name="password" placeholder="输入旧密码">
		</div>
		<div class="form-group">
			<input type="password" class="form-control input-lg" id="newPassword" name="newPassword" placeholder="输入新密码">
		</div>
		<div class="form-group">
			<input type="password" class="form-control input-lg" id="reNewPassword" name="reNewPassword" placeholder="重新输入新密码">
		</div>
		<button type="button" onclick="updatePassword();" class="btn btn-primary btn-lg btn-block">修改密码</button>
	</form>
	<br />
	<div class="heights">&nbsp;</div>
	<nav>
     
<dl>
  <dt>
    <a href="./index.html"><img
      src="./images/nav1.png" width="65" height="35" /></a>
  </dt>
  <dd>
    <a href="./index.html">首页</a>
  </dd>
</dl>
<dl>
  
  <dt>
    <a href="./search.html"><img
      src="./images/nav2.png" width="65" height="35" /></a>
  </dt>
  <dd>
    <a href="./search.html">精确查找</a>
  </dd>
  
  
</dl>
<dl>
  <dt>
    <a href="./novice.html"><img
      src="./images/nav3.png" width="65" height="35" /></a>
  </dt>
  <dd>
    <a href="./novice.html">新手教程</a>
  </dd>
</dl>

<dl>
  <dt>
    <a href="./toUserCenter.html"><img
      src="./images/nav4.png" width="65" height="35" /></a>
  </dt>
  <dd>
    <a href="./toUserCenter.html">会员中心</a>
  </dd>
</dl>


<div class="clearfix"></div>
    </nav>
		<!-- 模态框（Modal） -->
	<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
	   <div class="modal-dialog">
	      <div class="modal-content">
	         <div class="modal-header">
	            <button type="button" class="close" 
	               data-dismiss="modal" aria-hidden="true">
	                  &times;
	            </button>
	            <h4 class="modal-title" id="myModalLabel">
	               	修改密码提示
	            </h4>
	         </div>
	         <div class="modal-body" id="modelText">
	         </div>
	         <div class="modal-footer">
	            <button type="button" class="btn btn-default" 
	               data-dismiss="modal">关闭
	            </button>
	         </div>
	      </div><!-- /.modal-content -->
	</div><!-- /.modal -->
</body>
</html>